<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link href="/resource/css/assets/bootstrap.min.css" rel="stylesheet"/>
    <link href="/resource/css/style.css" rel="stylesheet"/>
    <link href="/resource/css/assets/codemirror.css" rel="stylesheet">
    <link rel="stylesheet" href="/resource/css/assets/ace.min.css"/>
    <link rel="stylesheet" href="/resource/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/resource/css/assets/font-awesome.min.css"/>
    <!--[if lte IE 8]>
    <link rel="stylesheet" href="/resource/css/assets/ace-ie.min.css"/>
    <![endif]-->
    <script src="/resource/js/jquery-1.9.1.min.js"></script>
    <script src="/resource/js/assets/bootstrap.min.js"></script>
    <script type="text/javascript" src="/resource/js/Validform.min.js"></script>
    <script src="/resource/js/assets/typeahead-bs2.min.js"></script>
    <script src="/resource/js/lrtk.js" type="text/javascript"></script>
    <link rel="stylesheet" href="/resource/common/layui/css/layui.css" media="all"/>
    <title>管理员</title>
</head>

<body>
<div class="page-content clearfix">
    <div class="administrator">
        <div class="d_Confirm_Order_style">

            <!--操作-->
            <div class="border clearfix">
       <span class="l_f">
        <a id="administrator_add" class="btn btn-warning addMenu"><i class="fa fa-plus"></i> 添加菜单</a>
       </span>
            </div>
            <!--用户列表-->
            <div class="clearfix administrator_style" id="administrator">
                <div class="left_style">
                    <div id="scrollsidebar" class="left_Treeview">
                        <div class="show_btn" id="rightArrow"><span></span></div>
                        <div class="widget-box side_content">
                            <div class="side_title"><a title="隐藏" class="close_btn"><span></span></a></div>
                            <div class="side_list">
                                <div class="widget-header header-color-green2"><h4 class="lighter smaller">父菜单列表</h4>
                                </div>
                                <div class="widget-body">
                                    <ul class="b_P_Sort_list">
                                        <li class="chose" th:each="sys:${sysList}" th:id="${sys.id}">
                                            <i class="fa fa-users green "></i> <a
                                                th:text="${sys.name}"></a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="table_menu_list" id="testIframe">
                    <table id="moduleTables" lay-filter="moduleTables" style="margin: 0 auto"></table>
                </div>
            </div>
        </div>
    </div>

</div>

</body>
</html>
<script type="text/html" id="operate">
    <a title="编辑" class="btn btn-xs btn-info" lay-event="edit"><i class="fa fa-edit bigger-120"></i></a>
    <a title="删除" class="btn btn-xs btn-warning" lay-event="del"><i class="fa fa-trash  bigger-120"></i></a>
</script>
<script type="text/javascript" src="/resource/common/layui/layui.js"></script>
<script type="text/javascript" src="/resource/js/assets/laydate/laydate.js"></script>
<script type="text/javascript">
    layui.use(['table', 'layer', 'laydate', 'form'], function () {
        var table = layui.table,
            $ = layui.$,
            layer = layui.layer,
            laydate = layui.laydate,
            form = layui.form;
        var permissionId;
        //菜单列表
        var tableIns = table.render({
            elem: '#moduleTables'
            , url: '/menu/menu.do' //数据接口
            , method: 'get'
            , even: true
            , page: true //开启分页
            , id: 'tableId'
            , limits: [10, 15, 30]
            , limit: 15
            , cols: [
                [ //表头
                    {field: 'permissionName', title: '名称'}
                    , {field: 'icon', title: '图标', width: 80}
                    , {field: 'priority', title: '优先级'}
                    , {field: 'permissionMark', title: '权限标识符'}
                    , {field: 'url', title: 'url(后台接口)'}
                    , {title: '操作', toolbar: '#operate', 'fixed': 'right'}
                ]
            ]
        });
        //角色筛选
        $('.chose').on('click', function () {
            permissionId = $(this).attr('id')
            console.log(permissionId)
            active.reload(permissionId)
        })
        //撤销
        $(".revocation").on('click', function () {
            $("#userName").val("");
            $("#iphone").val("");
            form.render();
            active.reload()
        });
        $(".addMenu").on('click', function () {
            if (permissionId == null) {
                permissionId == 0
            }
            layer.open({
                type: 2,
                title: "添加资源",
                shadeClose: false, //点击遮罩关闭层
                area: ['700px', '500px'],
                content: "/menu/addMenuHouser?parentId=" + permissionId
            })
        })
        //监听用户列工具条
        table.on('tool(moduleTables)', function (obj) {
            var data = obj.data;
            console.log(data);
            if (obj.event == "del") {
                layer.confirm('是否删除?', function (index) {
                    $.ajax({
                        url: "/menu/delMenu.do",
                        type: "post",
                        data: {"id": data.id},
                        dataType: "json",
                        success: function (result) {
                            if (!result.status) {
                                layer.msg(result.msg, {time: 2000});
                                return false;
                            }
                            layer.msg("删除成功!", {time: 1000});
                            active.reload();
                        }
                    });
                    layer.close(index);
                })
            } else if (obj.event == "edit") {
                layer.open({
                    type: 2,
                    title: "编辑资源",
                    shadeClose: false, //点击遮罩关闭层
                    area: ['500px', '300px'],
                    content: "/menu/editMenuHouser?permissionId=" + data.id
                })
            }
        });
        active = {
            reload: function (permissionId) {
                //执行重载
                table.reload('tableId', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        permissionId: permissionId
                    }
                });
            },

        };

        //删除用户函数
        function delUser(ids) {
            layer.confirm('确定要删除吗?', function (index) {
                $.ajax({
                    url: "/user/user.do",
                    type: "post",
                    data: {_method: "DELETE", "ids": ids},
                    dataType: "json",
                    success: function (result) {
                        if (!result.status) {
                            layer.msg(result.msg, {time: 2000});
                            return false;
                        }
                        layer.msg("删除成功!", {time: 1000});
                        active.reload();
                    }
                });
                layer.close(index);
            })
        }
    });
</script>
<script type="text/javascript">
    $(function () {
        $("#administrator").fix({
            float: 'left',
            //minStatue : true,
            skin: 'green',
            durationTime: false,
            spacingw: 50,//设置隐藏时的距离
            spacingh: 270,//设置显示时间距
        });
    });
    //初始化宽度、高度
    $(".widget-box").height($(window).height() - 215);
    $(".table_menu_list").width($(window).width() - 260);
    $(".table_menu_list").height($(window).height() - 215);
    //当文档窗口发生改变时 触发
    $(window).resize(function () {
        $(".widget-box").height($(window).height() - 215);
        $(".table_menu_list").width($(window).width() - 260);
        $(".table_menu_list").height($(window).height() - 215);
    })
    laydate({
        elem: '#start',
        event: 'focus'
    });
</script>

